import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.naming.InitialContext;
import javax.sql.DataSource;


public class TestarConexaoGlassfish {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		try {
			
			
			DataSource ds = (DataSource)new InitialContext(null).lookup("jdbc/ufpr");
			Connection con = ds.getConnection();
			
			String select = "SELECT * FROM venda.venda ";
			PreparedStatement ps = con.prepareStatement(select);
			ResultSet rs = ps.executeQuery();
			
			while(rs.next()) {
				System.out.print("\tVenda id:\t");
				System.out.print(rs.getInt("vendaID"));
				System.out.print("\tValor pago R$:\t");
				System.out.println(rs.getDouble("valorTotal"));
				
			}
		
			con.close();
			
		}catch(Exception e) {
			e.printStackTrace();
		}
		
		

	}

}
